package at.fhooe.mcm.lri.mdmpoc.warehouse.datamodel;


import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;


@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class TimingResult implements Comparable<Object> {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long key;

	@Persistent
	private String username;
	@Persistent
	private String action;	
	@Persistent
	private int items; // number of processed items
	@Persistent
	private double duration; 
	@Persistent
	private double cpuMegaCycles; 
	@Persistent
	private double cpuSeconds; 
	@Persistent
	private Date date;
	
	public TimingResult() {
	}

	public Long getKey() {
		return key;
	}

	public void setKey(Long key) {
		this.key = key;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public int getItems() {
		return items;
	}

	public void setItems(int items) {
		this.items = items;
	}

	public double getDuration() {
		return duration;
	}

	public void setDuration(double duration) {
		this.duration = duration;
	}

	public double getCpuMegaCycles() {
		return cpuMegaCycles;
	}

	public void setCpuMegaCycles(double cpuMegaCycles) {
		this.cpuMegaCycles = cpuMegaCycles;
	}

	public double getCpuSeconds() {
		return cpuSeconds;
	}

	public void setCpuSeconds(double cpuSeconds) {
		this.cpuSeconds = cpuSeconds;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Override
	public int compareTo(Object obj) {
		TimingResult tr2 = (TimingResult)obj;
		if (tr2.getDate().before(getDate())) {
			return -1;
		} else if (tr2.getDate().after(getDate())) {
			return 1;
		} else {
			return 0;
		}
			 
	}
}

